package com.ygp.dtp.core.support;

import com.ygp.dtp.common.config.properties.DtpProperties;
import com.ygp.dtp.common.constant.DynamicTpConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.ansi.AnsiColor;
import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.boot.ansi.AnsiStyle;

/**
 * @description: 动态数据源公告打印
 * @motto: 代码源于生活，高于生活艺术
 * @author: zhouhengzhe
 * @date: 2022/8/9 17:50
 * @since 1.0
 **/
@Slf4j
public class DtpBannerPrinter implements InitializingBean {

    private final DtpProperties dtpProperties;

    public DtpBannerPrinter(DtpProperties dtpProperties) {
        this.dtpProperties = dtpProperties;
    }


    @Override
    public void afterPropertiesSet() throws Exception {
        if (dtpProperties.isEnabledBanner()){
            log.info(AnsiOutput.toString(DynamicTpConstant.BANNER, "\n",
                    AnsiColor.GREEN,
                    DynamicTpConstant.NAME,
                    AnsiColor.DEFAULT,
                    AnsiStyle.FAINT));
        }
    }
}
